#include "FreeType.h"

namespace hgui
{
	void Font::initialise(std::string& filename, UInt32 h)
	{
		mTextures = new GLuint[128];
		mHeight = static_cast<float>(h);

		if (FT_Init_FreeType(&mLibrary))
		{
			MessageBox(NULL, "'FT_Init_FreeType' is failed.", "FreeType error", MB_OK | MB_ICONERROR);
			PostQuitMessage(1);
		}

		if (FT_New_Face(mLibrary, filename.c_str(), 0, &mFace))
		{
			MessageBox(NULL, "'FT_New_Face' is failed.", "FreeType error", MB_OK | MB_ICONERROR);
			PostQuitMessage(1);
		}

		FT_Set_Char_Size(mFace, h << 6, h << 6, 96, 96);

	}

	void Font::destroy()
	{
		FT_Done_Face(mFace);
		FT_Done_FreeType(mLibrary);

		glDeleteTextures(128, mTextures);
		delete [] mTextures;
		mTextures = nullptr;
	}
} // namespace hgui